Skip to content

feat(config): report config drift — the schema detector gets a caller, features get a detector - #512

Merged
sandstream merged 1 commit into
mainfrom
feat/511-config-drift
Aug 21, 2026
Merged

sandstream merged 1 commit into
mainfrom
feat/511-config-drift

Conversation

@sandstream

Copy link
Copy Markdown
Owner

Closes #511.

Two drifts, two missing readers

Schema drift had a detector and no caller. kit config migrate --check has answered this since versioning landed:

$ kit config migrate --check
✗ Config is at v0; current is v1. Run `kit config migrate`.        exit 1

kit status said only ✓ .kit.toml present, and present is not current. Measured on kit's own repo — the config was v0 while the schema was v1, unreported until someone asked directly. Now:

○ config schema  v0, current is v1  → run `kit config migrate`

The row goes through a new read-only planConfigMigration(): same detection, no write path at all. A test asserts the file is byte-identical afterwards, because a status row that can rewrite your config would be a worse defect than the one it fixes.

Feature drift had no detector. A long-lived .kit.toml does not know about [context], [policy.agent_writes], [deploy], [governance.audit] require_anchor. applyRecommendedHardening() knew the recommended posture and was reachable only from kit setup, which applies it — touching ~/.claude, ~/.codex and the repo's git hooks. So "what would I get?" could only be answered by letting it happen.

$ kit config recommend
kit config recommend  (nothing is written)
────────────────────────────────────────────────────────────
  ✓ cross-harness memory capture       transcripts from every agent land in one local store, so a later
                                       session can recall what was decided instead of re-deriving it
  ○ pre-commit secret scan             a staged credential is refused before it becomes git history,
                                       which is immutable
    → kit hooks add secret-scan
  ○ [context] CLI lock                 each CLI is pinned to the account + project this repo must use,
                                       so a tool answering as the wrong identity is a red row instead of
                                       a filtered result set that looks complete
    → kit context check  (prints a ready-to-paste block)
  ○ pre-push context check             a push to the wrong org/project is blocked before it leaves the machine
    → declare [context] first — the gate has nothing to compare against without it
  …

Two deliberate details:

On the shape this was raised as

Not a kit rebase verb. rebase already means something specific and different to every git user, and both halves here were a missing reader, not a missing command — the detection existed or the knowledge existed, and nothing surfaced either. Auto-migrating on load is also out: a config that changes shape underneath a running session is worse than one that is behind, and the schema version exists precisely so the change is explicit and reviewable.

One fixture was wrong, and the row was right

status.test.ts's "configured project: every signal on" built a fully-configured repo whose .kit.toml carried no version stamp — so the new row flagged it, correctly. The fixture now stamps CONFIG_SCHEMA_VERSION (from the constant, so it cannot rot behind it) rather than the row being softened to keep a green test.

Tests

src/config-drift.test.ts — 10:

  • planConfigMigration: legacy config reported behind with both versions named; a stamped config reported current; null rather than a guess for an absent or malformed config; and writes nothing (byte-identical file)
  • recommendPosture: nothing adopted for a bare config with every row carrying a non-trivial "buys" line and a how; declared sections marked adopted with the how dropped; the [context]-first ordering for the pre-push gate; installed git/memory hooks read as adopted
  • compiled CLI: kit status names the schema gap and the command that fixes it; kit config recommend --json returns the rows and leaves the directory listing unchanged

Verification

  • npm test: 4439 tests, 0 fail, 0 skipped (macOS, non-root)
  • kit self-audit: 16 rules, 0 fail, 0 warn — including undocumented commands, which the new subcommand had to satisfy (docs/COMMANDS.md)
  • eslint src: 0 errors · prettier --check "src/**/*.ts" clean

🤖 Generated with Claude Code

…, features get a detector

A .kit.toml falls behind in two ways and neither reached the operator (#511).

Schema drift had a working detector and no caller. `kit config migrate --check`
has answered "Config is at v0; current is v1" since versioning landed, while
`kit status` said only `✓ .kit.toml present` — and "present" is not "current".
Measured on kit's own repo: the config was v0 while the schema was v1, and
nothing said so until someone asked directly. `kit status` now carries a
`config schema` row via a new read-only `planConfigMigration()`, which answers
without any write path (asserted: the file is byte-identical afterwards).

Feature drift had no detector at all. A long-lived config does not know about the
sections kit has learned since — [context], [policy.agent_writes], [deploy],
[governance.audit] require_anchor. applyRecommendedHardening() knew the
recommended posture but was reachable only from `kit setup`, which APPLIES it,
touching ~/.claude, ~/.codex and the repo's git hooks — so asking "what would I
get?" meant letting it happen. New `kit config recommend [--json]` reports it and
writes nothing.

Each row says what the piece BUYS rather than that it is absent; a checklist of
missing features is how a report gets ignored. The pre-push context row points at
declaring [context] first rather than at installing a gate that cannot fail,
matching the refusal added in #497.

Deliberately not a `kit rebase` verb: rebase means something specific and
different to every git user, and both halves of this were a missing reader, not a
missing command. Auto-migrating on load is also out — a config that changes shape
underneath a session is worse than one that is behind.

One existing fixture asserted that a "fully configured" project has every signal
green while its .kit.toml carried no version stamp. The new row is right about
that, so the fixture now stamps CONFIG_SCHEMA_VERSION rather than the row being
softened.

Closes #511

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@github-actions

Copy link
Copy Markdown

✅ Docker image built successfully

  • CLI image: docker.io/sandstream/kit:test

@sandstream
sandstream merged commit cae7b3e into main Aug 21, 2026
19 checks passed
@sandstream
sandstream deleted the feat/511-config-drift branch August 21, 2026 09:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Config drift is silent both ways: the schema detector has no caller, and feature drift has no detector

1 participant